<template>
	<view>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-p-t-30" :class="{avatarBody:isAndroid}">
			<view class="u-m-r-10 vatar-body">

				<oss-upload></oss-upload>

			</view>
			<view class="u-flex-1" :class="{nameBody:isAndroid}">
				<view class="u-font-18 u-p-b-20">{{vuex_user.name}}</view>
				<view class="u-font-14 u-tips-color">微信号:{{vuex_user.email}}</view>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="scan" color="#969799" size="28"></u-icon>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="list" title="个人信息" @click="toBaseInfo"></u-cell-item>
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="order" title="所有订单"></u-cell-item>
				<u-cell-item icon="star" title="商品收藏" @click="toCollectGoods"></u-cell-item>
				<!-- <u-cell-item icon="photo" title="相册"></u-cell-item> -->
				<!-- <u-cell-item icon="coupon" title="卡券"></u-cell-item> -->
				<u-cell-item icon="map" title="收货地址"></u-cell-item>
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="setting" title="设置"></u-cell-item>
			</u-cell-group>
		</view>
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="close-circle" title="退出登录" @click="logout"></u-cell-item>
			</u-cell-group>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				isAndroid: false
			}
		},
		onLoad() {
			if (!this.$u.utils.isLogin()) return
			if (this.$u.utils.isAndroid()) {
				this.$u.toast('android')
				this.isAndroid = true
			}
			// console.log(111)
		},
		methods: {
			toBaseInfo() {
				this.$u.route({
					url: 'pages/center/baseInfo'
				})
			},
			toCollectGoods() {
				this.$u.route({
					url: 'pages/center/collectGoods'
				})
			},
			async logout() {
				//请求api
				await this.$u.api.authLogout()
				this.$u.toast('退出成功')
				setTimeout(() => {
					//清除缓存
					this.$u.vuex('vuex_token', null)
					this.$u.vuex('vuex_user', {})
					//跳转
					this.$u.route({
						type: 'reLaunch',
						url: 'pages/index/index'
					})
				}, 1500)

			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ededed;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}

	.vatar-body {
		height: 70px;
		width: 70px;
	}

	.avatarBody {
		padding: 30rpx 30rpx 70rpx !important;
	}

	.nameBody {
		margin-left: 50rpx;
		margin-top: 35rpx;
	}
</style>
